import { servicesGroup } from '../services/createServices';
import { headerModules } from '../utils/utils'
// middleware
export function servicesMiddleWare() {
  return (next) => (action) => {
    if (typeof action === 'object') {
      //如果当前action的type是'menu/updateAsideHighlight'
      if (action.type === 'menu/updateAsideHighlight') {
        const { ids } = action;
        const modules = headerModules(ids)
        servicesGroup.forEach((services) => {
          services.setRequestHeader({ modules });
        });
      }
    }
    return next(action);
  };
}
